$(function(){
	 
	$("#submit").click(function(){
		$('.datatable-basic').DataTable().draw();
	});

	$('select').select2({
	    minimumResultsForSearch: Infinity
	});

    var date_ = new Date();
    var year = date_.getFullYear();
    var month = date_.getMonth() + 1;
    var firstdate = year + '-' + month + '-01';//当月第一天
    var day = new Date(year,month,0);
    var lastdate = year + '-' + month + '-' + day.getDate();//当月最后一天
	
	$('#beginDate').daterangepicker(
			  { 
				  "singleDatePicker": true,
			    locale:{
			    	format: 'YYYY-MM-DD',
		            applyLabel: '确认',
		            cancelLabel: '取消',
		            fromLabel: '从',
		            toLabel: '到',
		            customRangeLabel: '选择时间',
		            daysOfWeek:["日","一","二","三","四","五","六"],
		            monthNames: ["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],
		        }
			  }
			);
	 $('#beginDate').val(firstdate);
	 
	 
	 $('#endDate').daterangepicker(
			  { 
				  "singleDatePicker": true,
			    locale:{
			    	format: 'YYYY-MM-DD',
		            applyLabel: '确认',
		            cancelLabel: '取消',
		            fromLabel: '从',
		            toLabel: '到',
		            customRangeLabel: '选择时间',
		            daysOfWeek:["日","一","二","三","四","五","六"],
		            monthNames: ["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],
		        }
			  }
			);
	 $('#endDate').val(lastdate);

    $('.datatable-basic').DataTable({
        "ajax" : {
            "url" : contextpath + "cOrderPayment/payTypeReport/list",
            "data" : function(d) {
                var query = $("#query").serializeObject();
                query["size"] = d.length;
                query["page"] = (d.start/d.length);
                return query;
            },
            "dataFilter": function(data){
                var json = jQuery.parseJSON( data );
                json.recordsTotal = json.totalElements;
                json.recordsFiltered = json.totalElements;
                json.data = json.content;

                return JSON.stringify( json );
            }
        },
        "columns": [
            { "data": "payTypeName" },
            { "data": "amount" },
            { "data": "feeAmount" },
            { "data": "kValue" }
        ],
        "drawCallback": function( settings ) {
            $("tr:eq(1)").css("color", "red");
        }
    }); 
})
